﻿CREATE TABLE [RestartFramework].[ETLJobHistory]
(
	[ETLJobHistoryId]				INT					NOT NULL
,	[ETLJobId]						SMALLINT			NOT NULL
--,	[execution_id]					BIGINT NOT NULL
,	[ETLJobHistoryStartTime]		DATETIMEOFFSET(7)	NOT NULL
,	[ETLJobHistoryEndTime]			DATETIMEOFFSET(7)	NULL
,	[StartedByServerExecutionId]	BIGINT				NOT NULL
,	[EndedByServerExecutionId]		BIGINT				NULL
,	[RestartTally]					SMALLINT			NOT NULL
,	CONSTRAINT [PK_RestartFrameworkETLJobHistory] PRIMARY KEY ([ETLJobHistoryId]) 
,	CONSTRAINT [FK_RestartFrameworkETLJobHistory_REF_RestartFrameworkETLJob] FOREIGN KEY ([ETLJobId])REFERENCES[RestartFramework].[ETLJob]([ETLJobId])
)

GO
EXEC sp_addextendedproperty @name = N'MS_Description',
    @value = N'Time at which this execution of the ETLJob started',
    @level0type = N'SCHEMA',
    @level0name = N'RestartFramework',
    @level1type = N'TABLE',
    @level1name = N'ETLJobHistory',
    @level2type = N'COLUMN',
    @level2name = N'ETLJobHistoryStartTime'
GO
EXEC sp_addextendedproperty @name = N'MS_Description',
    @value = N'Time at which this execution of the ETLJob ended',
    @level0type = N'SCHEMA',
    @level0name = N'RestartFramework',
    @level1type = N'TABLE',
    @level1name = N'ETLJobHistory',
    @level2type = N'COLUMN',
    @level2name = N'ETLJobHistoryEndTime'
GO
EXEC sp_addextendedproperty @name = N'MS_Description',
    @value = N'The execution_id that was assigned from the SSIS Catalog when this instance of the ETLJob started',
    @level0type = N'SCHEMA',
    @level0name = N'RestartFramework',
    @level1type = N'TABLE',
    @level1name = N'ETLJobHistory',
    @level2type = N'COLUMN',
    @level2name = N'StartedByServerExecutionId'
GO
EXEC sp_addextendedproperty @name = N'MS_Description',
    @value = N'The execution_id that was assigned from the SSIS Catalog when this instance of the ETLJob ended',
    @level0type = N'SCHEMA',
    @level0name = N'RestartFramework',
    @level1type = N'TABLE',
    @level1name = N'ETLJobHistory',
    @level2type = N'COLUMN',
    @level2name = N'EndedByServerExecutionId'
GO
EXEC sp_addextendedproperty @name = N'MS_Description',
    @value = N'A running count of the number of times this instance of the ETLJob was restarted',
    @level0type = N'SCHEMA',
    @level0name = N'RestartFramework',
    @level1type = N'TABLE',
    @level1name = N'ETLJobHistory',
    @level2type = N'COLUMN',
    @level2name = N'RestartTally'